package com.xiaodou.mjf.application.core.service.impl;

import com.xiaodou.mjf.application.core.repository.InvokeLogRepository;
import com.xiaodou.mjf.application.core.service.InvokeLogService;
import com.xiaodou.mjf.entity.core.InvokeLog;
import com.xiaodou.mjf.infrastructure.common.app.JpaSimpleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import javax.transaction.Transactional;


/***
 *
 * InvokeLog业务访问实现
 * @author XiaoDou.com Code Generator
 * @version 1.0
 * 2014-10-29 17:37:52
 *
 */
@Service @Transactional
public class InvokeLogServiceImpl extends JpaSimpleService<InvokeLog,String> implements InvokeLogService{

	Logger logger = LoggerFactory.getLogger(InvokeLogServiceImpl.class);

    @Resource
    InvokeLogRepository invokeLogRepository;

    @Override
    protected JpaRepository<InvokeLog, String> getRepository() {
        return invokeLogRepository;
    }

    @Override
    public InvokeLog getByOrderId(String orderId) {
        return invokeLogRepository.findOne((root,query,cb) ->{

            Predicate p1 = cb.equal(root.get("orderId").as(String.class),orderId);

            return query.where(p1).getRestriction();

        });
    }
}

